import createLogger from 'vuex/dist/logger'

const localStoragePlugin = store => {
  store.subscribe((mutation, state) => {
    Object.keys(state).forEach((item,index)=>{
      window.sessionStorage.setItem(item, JSON.stringify(state[item]))
    })
  })
}

export default process.env.NODE_ENV !== 'production'
  ? [createLogger({
    collapsed: true
  }), localStoragePlugin]
  : [localStoragePlugin]
